{extend name="public/layer_base"}

{block name="style"}
{js href="__PUBLIC__static/admin/lib/cropper/cropper.min.css"}
{css href="__PUBLIC__static/admin/lib/zTree/v3/css/zTreeStyle/zTreeStyle.css"}
{/block}

{block name="main"}
<div class="pos-a" style="width:150px;left:0;top:0; bottom:0; height:100%; border-right:1px solid #e5e5e5; background-color:#f5f5f5">
    <ul id="treeDemo" class="ztree">
    </ul>
</div>
<div style="margin-left:150px;">
<form action="{:url('save_article')}" method="post" class="form form-horizontal" id="form-send" enctype="multipart/form-data">
    <div class="row cl">
        <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>文章标题：</label>
        <div class="formControls col-xs-8 col-sm-9">
            <input type="text" class="input-text" name="title" value="{$data.title|default=''}">
        </div>
    </div>
    <div class="row cl">
        <label class="form-label col-xs-4 col-sm-2"><span class="c-red"></span>作者：</label>
        <div class="formControls col-xs-8 col-sm-9">
            <input type="text" class="input-text" name="author" value="{$data.author|default=''}">
        </div>
    </div>
    <div class="row cl">
        <label class="form-label col-xs-4 col-sm-2"><span class="c-red"></span>日期：</label>
        <div class="formControls col-xs-8 col-sm-9">
            <input type="text" class="input-text" name="create_time" value="{gt name='data.create_time|default="0"' value='0'}{$data.create_time|date='Y-m-d',###}{/gt}">
        </div>
    </div>
    <div class="row cl">
        <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>点击数：</label>
        <div class="formControls col-xs-8 col-sm-9">
            <input type="text" class="input-text" name="hits" value="{$data.hits|default=''}">
        </div>
    </div>
    <div class="row cl">
        <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>是否在首页显示：</label>
        <div class="formControls col-xs-8 col-sm-9"> <span class="select-box">
            <select class="select" name="index">
                <option value="">请选择</option>
                <option value="1" {eq name="data.index|default=0" value="1"} selected {/eq}>是</option>
                <option value="0" {eq name="data.index|default=0" value="0"} selected {/eq}>否</option>
            </select>
            </span>
        </div>
    </div>
    <div class="row cl">
        <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>封面图：</label>
        <div class="formControls col-xs-8 col-sm-9">
            <div class="col-md-6 l_image" style="padding: 0">
                <div class="img-preview img-preview-sm mb-20">
                    <img src="__PUBLIC__{$data.image|default=''}" style="width: 100%; height: 100%" />
                </div>
            </div>
            <div class="col-md-6 r_image" style="padding: 0">
                <div class="image-crop">
                    <img src="">
                </div>
                <div class="btn-group mt-20">
                    <label title="Upload image file" for="inputImage" class="btn btn-primary">
                        <input type="file" accept="image/*" id="inputImage" class="hide">
                        选择图片
                    </label>
                    <label title="Donload image" id="download" class="btn btn-warning">确认选择</label>
                    <label title="Donload image" id="image_close" class="btn btn-danger">取消</label>
                </div>
                <canvas id="myCanvas" style="display:none"></canvas>
            </div>
        </div>
    </div>
    <div class="row cl">
        <label class="form-label col-xs-4 col-sm-2">简介：</label>
        <div class="formControls col-xs-8 col-sm-9">
           <textarea style="width: 80%; height: 50px;" name="desc">{$data->articleDesc->desc|default=''}</textarea>
        </div>
    </div>
    <div class="row cl">
        <label class="form-label col-xs-4 col-sm-2">详细内容：</label>
        <div class="formControls col-xs-8 col-sm-9">
            <script id="editor" type="text/plain" style="width:100%;height:400px;">{$data->articleDesc->content|default=''}</script>
        </div>
    </div>
    <div class="row cl">
        <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
            <button class="btn btn-primary radius send_btn" type="submit"><i class="Hui-iconfont">&#xe632;</i> 保存并提交</button>
            <button onClick="layer_close();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
        </div>
    </div>
    <textarea name="content" style="display: none;">{$data->articleDesc->content|default=''}</textarea>
    <input type="hidden" name="category_id" value="{$data.category_id|default=0}" />
    <input type="hidden" name="image" value="{$data.image|default=''}" />
    <input type="hidden" name="id" value="{$data.id|default=0}" />
    <input type="hidden" name="__token__" value="{$Request.token}" />
</form>
</div>
{/block}

{block name="javascript"}
{js href="__PUBLIC__static/admin/lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"}

<script type="text/javascript">
$(function(){
    var zNodes ={$ztree};

    $(document).ready(function(){
        var t = $("#treeDemo");
        t = $.fn.zTree.init(t, SCOPE.category_ztree_setting, zNodes);
        var zTree = $.fn.zTree.getZTreeObj("treeDemo");
        zTree.selectNode(zTree.getNodeByParam("id",'{$data.category_id|default=0}'))
    });


    var ue = UE.getEditor('editor');

    $(".send_btn").click(function () {
        $('textarea[name="content"]').val(ue.getContent());
    });
});
</script>
{/block}